<template>
  <div class="container">
    <div class="hd">
      <h1 class="page_title">{{buildingName}}</h1>
    </div>
    <div class="weui_panel weui_panel_access" style="margin-bottom:10px;">
      <div class="weui_panel_bd">
        <div v-for="floor in floors" class="weui_media_box weui_media_text">
          <h4 class="weui_media_title">{{floor.name}}</h4>
          <p class="weui_media_desc">{{floor.content}}
          </p>
        </div>
      </div>
    </div>
    <partial name="footer-copyright"></partial>
  </div>
</template>
<style scoped>
.hd {
  padding: .5em 0;
}

.page_title {
  text-align: center;
  font-size: 20px;
  color: #B86086;
  font-weight: 400;
  margin: 0 5%;
}
</style>
<script>
import _ from 'underscore'

export default {
  name: 'HospFloorView',
  data: function () {
    return {
      buildingId: '',
      buildingName: '',
      floors: []
    }
  },
  ready: function () {
    this.buildingId = this.$route.query.buildingId
    this.buildingName = this.$route.query.buildingName
    this.getHospFloor()
  },
  methods: {
    getHospFloor: function () {
      var self = this
      this.$ajax.get('GetHospFloor', 'Hosp', { buildingId: this.buildingId }).then(function (data) {
        if (data.ResultCode === '0') {
          self.floors = _.map(data.Floors, function (val) {
            return {
              name: val.Name,
              content: val.Content
            }
          })
        }
      })
    }
  }
}
</script>
